/**
 * Copyright (c) 2009-2011, chunquedong(YangJiandong)
 * 
 * This file is part of ChunMap project
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
 * 
 * History:
 *     2010-05-05  Jed Young  Creation
 */
package chunmap.app.command;

import chunmap.app.MapCtrl;
import chunmap.app.bench.Command;
import chunmap.model.coord.Coordinate2D;
/**
 * @author chunquedong
 * 
 */
public class MoveToCommand implements Command {

	private MapCtrl map;
	private double x;
    private double y;
    private double ox;
    private double oy;

	public MoveToCommand(MapCtrl map, double x, double y) {
		this.map = map;
        this.x = x;
        this.y = y;

        ox = map.getView().getCenter().getX();
        oy = map.getView().getCenter().getY();
	}

	@Override
	public void execute() {
		//map.getView().pan(x, y);
		map.getView().setCenter(new Coordinate2D(x,y));
	}

	@Override
	public boolean isUndoable() {
		return true;
	}

	@Override
	public void rollback() {
		//map.getView().pan(-x, -y);
		map.getView().setCenter(new Coordinate2D(ox,oy));
	}

}